package ws.jdbc.concurrent.test.tasks.insert;

import java.sql.*;
import ws.jdbc.concurrent.test.tasks.ResultSetRunnable;

/**
 * This task inserts data directly into a {@link ResultSet}.
 * 
 * @author Wilson Santos, 36228 <wilson.santos@ua.pt>
 */
public class ResultSetInsert extends ResultSetRunnable {

  private int insertCount = 0;

  public ResultSetInsert() throws SQLException {
    super();
    insertCount = InsertParameters.insertCount;
  }

  public void run() {
    try {
      for (int i = 0; i < insertCount; i++) {
        rs.moveToInsertRow();
        rs.updateInt(1, num);
        rs.updateString(2, str1);
        rs.updateString(3, str2);
        rs.updateFloat(4, decimal);
        rs.insertRow();
      }
      st.close();
    } catch (SQLException ex) {
      ex.printStackTrace();
    }
  }
}
